﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NCrawler.Extensions;

namespace ZCrawler
{
    public enum TrimMethod
    {
        Start,
        End,
        Both
    }
    public class ZCrawlDataTrimmingProcessor : ZCrawlDataProcessor
    {
        public string StringToTrim { get; set; }
        public TrimMethod method { get; set; }
        public override string Process(string str)
        {
            string result = str;
            switch(method)
            {
                case TrimMethod.Both:
                    result = str.Trim(StringToTrim.ToArray());
                    break;
                case TrimMethod.End:
                    result = str.TrimEnd(StringToTrim.ToArray());
                    break;
                case TrimMethod.Start:
                    result = str.TrimStart(StringToTrim.ToArray());
                    break;
            }
            return result;
        }

        public override string Description
        {
            get
            {
                return "Trim -- method : {0}".FormatWith(method.ToString());
            }
        }
    }
}
